<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


Route::group(['prefix' => 'admin'], function () {
    //登录页面
    Route::get('/login', '\App\Admin\Controllers\LoginController@index');
    //登录行为
    Route::post('/login', '\App\Admin\Controllers\LoginController@login');
    //登出
    Route::get('/logout', '\App\Admin\Controllers\LoginController@logout');

    Route::group(['middleware' => 'auth:admin'], function() {
        //后台首页
        Route::get('/home', '\App\Admin\Controllers\HomeController@index');

        Route::group(['middleware' => 'can:sys'], function() {
            //管理人员列表页面
            Route::get('/users', '\App\Admin\Controllers\UserController@index');
            //管理人员添加页面
            Route::get('/users/create', '\App\Admin\Controllers\UserController@create');
            //管理人员添加行为
            Route::post('/users/store', '\App\Admin\Controllers\UserController@store');
            //用户的角色
            Route::get('/users/{user}/role', '\App\Admin\Controllers\UserController@role');
            //保存用户的角色
            Route::post('/users/{user}/role', '\App\Admin\Controllers\UserController@storeRole');

            //角色(角色列表、角色创建、保存角色)
            Route::get('/roles', '\App\Admin\Controllers\RoleController@index');
            Route::get('/roles/create', '\App\Admin\Controllers\RoleController@create');
            Route::post('/roles/store', '\App\Admin\Controllers\RoleController@store');
            Route::get('/roles/{role}/permission', '\App\Admin\Controllers\RoleController@permission');
            Route::post('/roles/{role}/permission', '\App\Admin\Controllers\RoleController@storePermission');

            //权限(权限列表、权限创建、保存权限)
            Route::get('/permissions', '\App\Admin\Controllers\PermissionController@index');
            Route::get('/permissions/create', '\App\Admin\Controllers\PermissionController@create');
            Route::post('/permissions/store', '\App\Admin\Controllers\PermissionController@store');
        });


        //文章相关权限
        Route::group(['middleware' => 'can:post'], function() {
            //文章审核列表
            Route::get('/posts', '\App\Admin\Controllers\PostController@index');
            //文章审核列表
            Route::post('/posts/{post}/status', '\App\Admin\Controllers\PostController@status');
        });

        //专题模块
        Route::group(['middleware' => 'can:topic'], function() {
           Route::resource('topics', '\App\Admin\Controllers\TopicController', ['only' => ['index', 'create', 'store', 'destroy']]);
        });

        //通知模块
        Route::group(['middleware' => 'can:notice'], function() {
            Route::resource('notices', '\App\Admin\Controllers\NoticeController', ['only' => ['index', 'create', 'store']]);
        });
    });

});

//用户注册行为

